<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { customertype, setCustomertype } from '../glob.js';

const router = useRouter();
const userName = ref('');
const password = ref('');

const login = () => {
  if (userName.value === "lxj" && password.value === "123") {
    setCustomertype(1); 
  }

    router.push({
        path: `/home/${userName.value}`,
    });
};
</script>

<template>
  <div class="page-container">
    <div class="login-container">
      <div class="logo">
        <i class="fa-solid fa-stethoscope fa-3x"></i>
        <h1>门诊医生工作站</h1>
      </div>
      <p>请先登录</p>
      <div class="input-group">
        <label for="username">用户名：</label>
        <input type="text" id="username" v-model="userName" placeholder="请输入用户名" />
      </div>
      <div class="input-group">
        <label for="password">密码：</label>
        <input type="password" id="password" v-model="password" placeholder="请输入密码" />
      </div>
      <button @click="login">登录</button>
    </div>
  </div>
</template>

<style scoped>
/* 引入 Font Awesome 图标库 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css');

.page-container {
  min-height: 100vh;
  background-image: linear-gradient(to bottom, #ffffff, #e0f2ff);
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-container {
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  padding: 30px;
  width: 400px;
  text-align: center;
  transition: all 0.3s ease;
  transform: scale(1);
  border: 1px solid #e0e0e0;
}



.logo {
  margin-bottom: 20px;
}

.logo i {
  color: #007BFF;
  margin-bottom: 10px;
}

h1 {
  color: #333;
  font-size: 30px;
  margin-bottom: 10px;
}

p {
  color: #666;
  font-size: 16px;
  margin-bottom: 25px;
}

.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  font-size: 16px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
  transition: border-color 0.3s ease;
  font-size: 16px;
}

.input-group input:focus {
  outline: none;
  border-color: #007BFF;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

button {
  background-color: #007BFF;
  color: white;
  padding: 14px 30px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}
</style>